var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var ResKeeper = require("AA_ResKeeper");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_LiuXue = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.xuedi = null;
    t.mosteids = {
      1: {
        w: 123,
        h: 123
      }
    };
    t.pool = null;
    t.saveNodes = [];
    t.tw = null;
    t.offtime = 0;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onEnable = function () {
    var e = this;
    this.node.children.forEach(function (t) {
      t.scale = 0;
      t.opacity = 0;
      e.huishouNode(t);
    });
    this.sendXueDi();
  };
  _creator.prototype.getLiuXueNode = function () {
    var e = this.saveNodes.shift();
    if (!e) {
      e = cc.instantiate(this.xuedi);
      this.node.addChild(e);
    }
    return e;
  };
  _creator.prototype.huishouNode = function (e) {
    this.saveNodes.push(e);
  };
  _creator.prototype.generateRandomPoint = function (e, t) {
    var o = 2 * Math.random() * Math.PI;
    var n = Math.random() * t;
    return e.add(new cc.Vec2(Math.cos(o) * n, Math.sin(o) * n));
  };
  _creator.prototype.sendXueDi = function () {
    var e = this;
    var t = this.getRandomPosition(this.node.getBoundingBox());
    var o = this.getLiuXueNode();
    o.x = t.x;
    o.y = t.y;
    o.scale = 0;
    o.opacity = 0;
    this.tw = cc.tween(o).to(.1, {
      scale: 1.2,
      opacity: 255
    }).to(.5, {
      scale: 0,
      opacity: 0,
      y: o.y - 150
    }).call(function () {
      e.huishouNode(o);
    }).start();
  };
  _creator.prototype.getRandomPosition = function (e) {
    var t = e.x + Math.random() * e.width;
    var o = e.y + Math.random() * e.height + 50;
    return new cc.Vec2(t, o);
  };
  _creator.prototype.update = function (e) {
    this.offtime += e;
    if (this.offtime > .2) {
      this.sendXueDi();
      this.offtime = 0;
    }
  };
  _creator.prototype.onDisable = function () {
    var e = this;
    if (this.tw) {
      this.tw.stop();
      this.node.children.forEach(function (t) {
        t.scale = 0;
        t.opacity = 0;
        e.huishouNode(t);
      });
    }
  };
  __decorate([_property(cc.Node)], _creator.prototype, "xuedi", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_UI_LiuXue;